package com.songtai.dao.impl;

import org.hibernate.SessionFactory;

import com.songtai.dao.IntroduceDao;
import com.songtai.po.Introduce;

/**
 * @author 赵中杨
 * @email zhaozhongyang717@gmail.com
 * @date 2010 2010-4-20 下午04:15:03
 */
public class IntroduceDaoImpl implements IntroduceDao {
	private SessionFactory sessionFactory;

	@Override
	public void addIntroduce(Introduce introduce) {
		this.sessionFactory.getCurrentSession().persist(introduce);
	}

	@Override
	public Introduce getIntroduceByNid(Long nodeid) {
		return (Introduce) this.sessionFactory.getCurrentSession().createQuery("from Introduce p where p.nid=:nid").setLong("nid", nodeid).uniqueResult();
	}

	@Override
	public void updateIntroduce(Introduce introduce) {
		this.sessionFactory.getCurrentSession().update(introduce);
	}

	@Override
	public Introduce getIntroduceById(String id) {
		return (Introduce) this.sessionFactory.getCurrentSession().get(Introduce.class, id);
	}

	/**
	 * @return the sessionFactory
	 */
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	/**
	 * @param sessionFactory
	 *            the sessionFactory to set
	 */
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

}
